﻿Public Class FormServiceCategory
    Dim DACategoryServise As New DSReservationTableAdapters.SERVICE_CATEGORYTableAdapter
    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        If ValidateTextField(TxtCategoryServie, "", ErrService) = False Then Exit Sub
        If LblSaveOption.Text = "0" Then
            If MessageBox.Show("Do you want to save new category?", "Service", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DACategoryServise.NewServiceCategory(TxtCategoryServie.Text) = 1 Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error save new service category.", "Service", MessageBoxButtons.OK)
                End If
            End If
        Else
            If MessageBox.Show("Do you want to update category?", "Service", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DACategoryServise.UpdateServiceCategory(TxtCategoryServie.Text, LblSaveOption.Text) = 1 Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error save new service category.", "Service", MessageBoxButtons.OK)
                End If
            End If
        End If
    End Sub

    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Me.Close()
    End Sub
End Class